/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ManagedBeans;

import Beans.Poke;
import Beans.User;
import dao.PokeDao;
import dao.UserDao;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import javax.faces.bean.RequestScoped;

/**

 @author Marie-Claude
 */
@ManagedBean(name = "userProfileManager")
@RequestScoped
public class UserProfileManager implements Serializable {

  private User user;
  @ManagedProperty(value = "#{userListManager}")
  private UserListManager mbUserList;
  @ManagedProperty(value = "#{userManager}")
  private UserManager mbUser;
  @ManagedProperty(value = "#{pokeManager}")
  private PokeManager mbPoke;
  private Poke poke;
  private int sendToUserId;
  private String sendToUsername;

  /**
   Creates a new instance of UserProfileManager
   */
  public UserProfileManager() {
  }

  public User getUser() {
    return user;
  }

  public void setUser(User user) {
    this.user = user;
  }

  public UserListManager getMbUserList() {
    return mbUserList;
  }

  public void setMbUserList(UserListManager mbUserList) {
    this.mbUserList = mbUserList;
  }

  public int getSendToUserId() {
    return sendToUserId;
  }

  public void setSendToUserId(int sendToUserId) {
    this.sendToUserId = sendToUserId;
  }

  public String getSendToUsername() {
    return sendToUsername;
  }

  public void setSendToUsername(String sendToUsername) {
    this.sendToUsername = sendToUsername;
  }

  public UserManager getMbUser() {
    return mbUser;
  }

  public void setMbUser(UserManager mbUser) {
    this.mbUser = mbUser;
  }

  public PokeManager getMbPoke() {
    return mbPoke;
  }

  public void setMbPoke(PokeManager mbPoke) {
    this.mbPoke = mbPoke;
  }

  public Poke getPoke() {
    return poke;
  }

  public void setPoke(Poke poke) {
    this.poke = poke;
  }

  public void initProfileRecherche(User userId) {

  }

  @PostConstruct
  public void init() {
    user = UserDao.getUserById(mbUserList.getIdUserToLook());
    sendToUsername = mbUserList.getUsernameUserToLook();
  }

  public String sendMessage(String username) {
    sendToUsername = username;
    return "sendMessage";
  }

  public String sendWink(String username) {
    sendToUsername = username;
    poke = new Poke();
    poke.setIdPokingUser(mbUser.getUser().getUserID());
    poke.setIdPokedUser(UserDao.getIdByUsername(username));
    PokeDao.sendWink(poke);
    return null;

  }
}
